﻿using System;
using System.Web;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Security;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Xml;
using System.Net;
using System.Collections.Generic;
using System.Text.RegularExpressions;

/// <summary>
///Aboutbank 的说明
///和银行相关的类
/// </summary>
public static class Aboutbank
{
    private static string getv1time()
    {
        string timestamp = readUrl("http://api.ulpos.com/v1/time");       
        return timestamp;
    }
    #region 网页读取gb2312
    public static String readgb2312Url(string url)
    {
        try
        {

            if (url != null && url.Length > 4)
            {
                string htmlBody = "";
                HttpWebRequest wr_time = (HttpWebRequest)HttpWebRequest.Create(url);
                using (StreamReader sr_time = new StreamReader(wr_time.GetResponse().GetResponseStream(), Encoding.GetEncoding("gb2312")))
                {
                    htmlBody = sr_time.ReadToEnd();
                }
                if (htmlBody == null || htmlBody.Length < 1)
                {
                    return "";
                }
                else
                {
                    return htmlBody;
                }
            }
            return "";
        }
        catch
        {
            return "";
        }
    }
    #endregion
    #region 网页读取
    public static string getXML(String URLString)
    {
        XmlTextReader reader = new XmlTextReader(URLString);
        StringBuilder sb = new StringBuilder();
        while (reader.Read())
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Text: //Display the text in each element.
                    sb.Append(reader.Value);
                    sb.Append(";");
                    break;
            }
        }
        return sb.ToString();
    }
    public static String readUrl(string url)
    {
        try
        {

            if (url != null && url.Length > 4)
            {
                string htmlBody = "";
                HttpWebRequest wr_time = (HttpWebRequest)HttpWebRequest.Create(url);
                using (StreamReader sr_time = new StreamReader(wr_time.GetResponse().GetResponseStream(), Encoding.GetEncoding("utf-8")))
                {
                    htmlBody = sr_time.ReadToEnd();
                }
                if (htmlBody == null || htmlBody.Length < 1)
                {
                    return "";
                }
                else
                {
                    return htmlBody;
                }
            }
            return "";
        }
        catch
        {
            return "";
        }
    }
    public static string appkey = "1161439";
    public static string appsecretAndMd5 = "sgidkndzgqeq1jhkp0oueqb5exr5sweamd5";
    public static String readAuthorizeUrl(string url, string para)
    {
        ////读取标准时间戳//////string timestamp = readUrl("http://api.ulpos.com/v1/time");
        string timestamp = getv1time();
        if (timestamp == null || timestamp.Length < 1)
        {
            return "";
        }
        else
        {
            string appendpara = "";
            if (para != null && para.Length > 0)
            {
                appendpara = para;
            }
            string sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(appkey + timestamp + appsecretAndMd5, System.Web.Configuration.FormsAuthPasswordFormat.MD5.ToString()).ToLower();

            return readUrl(url + "?appkey=" + appkey + "&signature_method=md5&timestamp=" + timestamp + "&sign=" + sign + "&gb=1" + appendpara);
        }
    }
    public static T readAuthorizeUrl<T>(string url, string para, out bool issuc) where T : new()
    {
        issuc = false;
        string getcont = readAuthorizeUrl(url, para);
        if (getcont != null && getcont.Length > 8)
        {
            if ("0".Equals(getcont.Substring(8, 1)))
            {
                issuc = true;
                return Convertjson.GetModel<T>(getcont);
            }
        }
        return default(T);
    }


    public static T readAuthorizeUrl<T>(string url, string para, out bool issuc, out string getstrcont) where T : new()
    {
        issuc = false;
        string getcont = readAuthorizeUrl(url, para);
        getstrcont = getcont;
        if (getcont != null && getcont.Length > 8)
        {
            if ("0".Equals(getcont.Substring(8, 1)))
            {
                issuc = true;
                return Convertjson.GetModel<T>(getcont);
            }
        }
        return default(T);
    }



    public static bool readSucAuthorizeUrl(string url, string para, out string loadret)
    {

        bool issuc = false;
        loadret = null;
        try
        {
            string getcont = readAuthorizeUrl(url, para);
            if (getcont != null && getcont.Length > 8)
            {
                loadret = getcont;
                if ("0".Equals(getcont.Substring(8, 1)))
                {
                    issuc = true;
                }
            }
        }
        catch
        {
            issuc = false;
        }
        return issuc;
    }
    public static T LoadModel<T>(string cont) where T : new()
    {
        return LitJson.JsonMapper.ToObject<T>(cont);
    }
    #endregion

    public static string getCardNoString(string cardno)
    {
        if (cardno != null && cardno.Length > 9)
        {
            return cardno.Substring(0, 4) + "***" + cardno.Substring(cardno.Length - 6);
        }
        return cardno;
    }
 
    public static bool getP_C_byIP(string ip, out string pc_name)
    {
        pc_name = null;
        if (ip == null || ip.Length < 5)
        {
            return false;
        }
        if ("127.0.0.1".Equals(ip))
        {
            pc_name = "辽宁大连";
            return true;
        }
        try
        {
            string strjs = "";
            string p_cityname;
            string p_name = "";
            string c_name = "";
            string htmlBody = readgb2312Url("http://www.ip138.com/ips138.asp?ip=" + ip);
            Regex r = new Regex("<td align=\"center\"><ul class=\"ul1\"><li>本站主数据：[\\w\\W\\s\\S]+</li><li>参考数据", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            if (r.IsMatch(htmlBody))
            {
                MatchCollection mc = r.Matches(htmlBody);
                if (mc.Count > 0)
                {
                    strjs = mc[0].Groups[0].Value;
                }
                if (strjs != null && strjs.Length > 45)
                {
                    p_cityname = strjs.Substring(45);
                    if (p_cityname != null && p_cityname.Length > 13)
                    {
                        p_cityname = p_cityname.Substring(0, p_cityname.Length - 13);
                    }
                    int sindex = p_cityname.IndexOf("联通");
                    if (sindex > 0)
                    {
                        p_cityname = p_cityname.Substring(0, sindex);
                    }
                    sindex = p_cityname.IndexOf(" 电信");
                    if (sindex > 0)
                    {
                        p_cityname = p_cityname.Substring(0, sindex);
                    }
                    sindex = p_cityname.IndexOf(" 移动");
                    if (sindex > 0)
                    {
                        p_cityname = p_cityname.Substring(0, sindex);
                    }
                    sindex = p_cityname.IndexOf(" 铁通");
                    if (sindex > 0)
                    {
                        p_cityname = p_cityname.Substring(0, sindex);
                    }
                    p_cityname = p_cityname.Trim();
                    sindex = p_cityname.IndexOf("省");
                    if (sindex > 0)
                    {
                        p_name = p_cityname.Substring(0, sindex);
                        int sindex2 = p_cityname.IndexOf("市");
                        if (sindex2 > 0)
                        {
                            c_name = p_cityname.Substring(sindex + 1, sindex2 - sindex - 1);
                        }
                        else
                        {
                            sindex2 = p_cityname.IndexOf("地区");
                            if (sindex2 > 0)
                            {
                                c_name = p_cityname.Substring(sindex + 1, sindex2 - sindex - 1);
                            }
                        }
                    }
                    else
                    {
                        sindex = p_cityname.IndexOf("自治区");
                        if (sindex > 0)
                        {
                            p_name = p_cityname.Substring(0, sindex);
                            int sindex2 = p_cityname.IndexOf("市");
                            if (sindex2 > 0)
                            {
                                c_name = p_cityname.Substring(sindex + 3, sindex2 - sindex - 3);
                            }
                            else
                            {
                                sindex2 = p_cityname.IndexOf("地区");
                                if (sindex2 > 0)
                                {
                                    c_name = p_cityname.Substring(sindex + 3, sindex2 - sindex - 3);
                                }
                            }
                        }
                    }
                }
                if (p_name != null && p_name.Length > 0)
                {
                    string find = pc_name_NameToId(p_name + c_name);
                    if (find != null && find.Length > 0)
                    {
                        pc_name = p_name + c_name;
                        return true;
                    }
                    else
                    {
                        find = P31_NameToP_C(p_name);
                        if (find != null && find.Length > 0)
                        {
                            pc_name = find;
                            return true;
                        }
                    }
                }
            }
        }
        catch
        {
        }
        return false;
    }
    public static string no_pc_name = "无";
    public static string no_pc_name_Id = "";
    public static string pc_name_IdToName(string id)
    {
        if (id == null || id.Length < 1)
        {
            return no_pc_name;
        }
        switch (id)
        {
            case "1": return "安徽合肥";
            case "2": return "安徽安庆";
            case "3": return "安徽蚌埠";
            case "4": return "安徽亳州";
            case "5": return "安徽巢湖";
            case "6": return "安徽池州";
            case "7": return "安徽滁州";
            case "8": return "安徽阜阳";
            case "9": return "安徽淮北";
            case "10": return "安徽淮南";
            case "11": return "安徽黄山";
            case "12": return "安徽六安";
            case "13": return "安徽马鞍山";
            case "14": return "安徽宿州";
            case "15": return "安徽铜陵";
            case "16": return "安徽芜湖";
            case "17": return "安徽宣城";
            case "18": return "北京北京";
            case "19": return "重庆重庆";
            case "20": return "福建福州";
            case "21": return "福建龙岩";
            case "22": return "福建南平";
            case "23": return "福建宁德";
            case "24": return "福建莆田";
            case "25": return "福建泉州";
            case "26": return "福建三明";
            case "27": return "福建厦门";
            case "28": return "福建漳州";
            case "29": return "甘肃兰州";
            case "30": return "甘肃白银";
            case "31": return "甘肃定西";
            case "32": return "甘肃甘南";
            case "33": return "甘肃嘉峪关";
            case "34": return "甘肃金昌";
            case "35": return "甘肃酒泉";
            case "36": return "甘肃临夏";
            case "37": return "甘肃陇南";
            case "38": return "甘肃平凉";
            case "39": return "甘肃庆阳";
            case "40": return "甘肃天水";
            case "41": return "甘肃武威";
            case "42": return "甘肃张掖";
            case "43": return "广东广州";
            case "44": return "广东深圳";
            case "45": return "广东东莞";
            case "46": return "广东珠海";
            case "47": return "广东中山";
            case "48": return "广东佛山";
            case "49": return "广东潮州";
            case "50": return "广东河源";
            case "51": return "广东惠州";
            case "52": return "广东江门";
            case "53": return "广东揭阳";
            case "54": return "广东茂名";
            case "55": return "广东梅州";
            case "56": return "广东清远";
            case "57": return "广东汕头";
            case "58": return "广东汕尾";
            case "59": return "广东韶关";
            case "60": return "广东阳江";
            case "61": return "广东云浮";
            case "62": return "广东湛江";
            case "63": return "广东肇庆";
            case "64": return "广西南宁";
            case "65": return "广西百色";
            case "66": return "广西北海";
            case "67": return "广西崇左";
            case "68": return "广西防城港";
            case "69": return "广西贵港";
            case "70": return "广西桂林";
            case "71": return "广西河池";
            case "72": return "广西贺州";
            case "73": return "广西来宾";
            case "74": return "广西柳州";
            case "75": return "广西钦州";
            case "76": return "广西梧州";
            case "77": return "广西玉林";
            case "78": return "贵州贵阳";
            case "79": return "贵州安顺";
            case "80": return "贵州毕节";
            case "81": return "贵州六盘水";
            case "82": return "贵州黔东南";
            case "83": return "贵州黔南";
            case "84": return "贵州黔西南";
            case "85": return "贵州铜仁";
            case "86": return "贵州遵义";
            case "87": return "海南海口";
            case "88": return "海南白沙";
            case "89": return "海南保亭";
            case "90": return "海南昌江";
            case "91": return "海南澄迈";
            case "92": return "海南儋州";
            case "93": return "海南定安";
            case "94": return "海南东方";
            case "95": return "海南乐东";
            case "96": return "海南临高";
            case "97": return "海南陵水";
            case "98": return "海南琼海";
            case "99": return "海南琼中";
            case "100": return "海南三亚";
            case "101": return "海南屯昌";
            case "102": return "海南万宁";
            case "103": return "海南文昌";
            case "104": return "海南五指山";
            case "105": return "海南西南中沙群岛办事处";
            case "106": return "河北石家庄";
            case "107": return "河北保定";
            case "108": return "河北沧州";
            case "109": return "河北承德";
            case "110": return "河北邯郸";
            case "111": return "河北衡水";
            case "112": return "河北廊坊";
            case "113": return "河北秦皇岛";
            case "114": return "河北唐山";
            case "115": return "河北邢台";
            case "116": return "河北张家口";
            case "117": return "河南郑州";
            case "118": return "河南安阳";
            case "119": return "河南鹤壁";
            case "120": return "河南济源";
            case "121": return "河南焦作";
            case "122": return "河南开封";
            case "123": return "河南洛阳";
            case "124": return "河南漯河";
            case "125": return "河南南阳";
            case "126": return "河南平顶山";
            case "127": return "河南濮阳";
            case "128": return "河南三门峡";
            case "129": return "河南商丘";
            case "130": return "河南新乡";
            case "131": return "河南信阳";
            case "132": return "河南许昌";
            case "133": return "河南周口";
            case "134": return "河南驻马店";
            case "135": return "黑龙江哈尔滨";
            case "136": return "黑龙江大庆";
            case "137": return "黑龙江大兴安岭";
            case "138": return "黑龙江鹤岗";
            case "139": return "黑龙江黑河";
            case "140": return "黑龙江鸡西";
            case "141": return "黑龙江佳木斯";
            case "142": return "黑龙江牡丹江";
            case "143": return "黑龙江七台河";
            case "144": return "黑龙江齐齐哈尔";
            case "145": return "黑龙江双鸭山";
            case "146": return "黑龙江绥化";
            case "147": return "黑龙江伊春";
            case "148": return "湖北武汉";
            case "149": return "湖北鄂州";
            case "150": return "湖北恩施";
            case "151": return "湖北黄冈";
            case "152": return "湖北黄石";
            case "153": return "湖北荆门";
            case "154": return "湖北荆州";
            case "155": return "湖北潜江";
            case "156": return "湖北神农架林区";
            case "157": return "湖北十堰";
            case "158": return "湖北随州";
            case "159": return "湖北天门";
            case "160": return "湖北仙桃";
            case "161": return "湖北咸宁";
            case "162": return "湖北襄樊";
            case "163": return "湖北孝感";
            case "164": return "湖北宜昌";
            case "165": return "湖南长沙";
            case "166": return "湖南常德";
            case "167": return "湖南郴州";
            case "168": return "湖南衡阳";
            case "169": return "湖南怀化";
            case "170": return "湖南娄底";
            case "171": return "湖南邵阳";
            case "172": return "湖南湘潭";
            case "173": return "湖南湘西";
            case "174": return "湖南益阳";
            case "175": return "湖南永州";
            case "176": return "湖南岳阳";
            case "177": return "湖南张家界";
            case "178": return "湖南株洲";
            case "179": return "吉林长春";
            case "180": return "吉林白城";
            case "181": return "吉林白山";
            case "182": return "吉林吉林";
            case "183": return "吉林辽源";
            case "184": return "吉林四平";
            case "185": return "吉林松原";
            case "186": return "吉林通化";
            case "187": return "吉林延吉";
            case "188": return "江苏南京";
            case "189": return "江苏常州";
            case "190": return "江苏淮安";
            case "191": return "江苏连云港";
            case "192": return "江苏南通";
            case "193": return "江苏苏州";
            case "194": return "江苏宿迁";
            case "195": return "江苏泰州";
            case "196": return "江苏无锡";
            case "197": return "江苏徐州";
            case "198": return "江苏盐城";
            case "199": return "江苏扬州";
            case "200": return "江苏镇江";
            case "201": return "江西南昌";
            case "202": return "江西抚州";
            case "203": return "江西赣州";
            case "204": return "江西吉安";
            case "205": return "江西景德镇";
            case "206": return "江西九江";
            case "207": return "江西萍乡";
            case "208": return "江西上饶";
            case "209": return "江西新余";
            case "210": return "江西宜春";
            case "211": return "江西鹰潭";
            case "212": return "辽宁沈阳";
            case "213": return "辽宁鞍山";
            case "214": return "辽宁本溪";
            case "215": return "辽宁朝阳";
            case "216": return "辽宁大连";
            case "217": return "辽宁丹东";
            case "218": return "辽宁抚顺";
            case "219": return "辽宁阜新";
            case "220": return "辽宁葫芦岛";
            case "221": return "辽宁锦州";
            case "222": return "辽宁辽阳";
            case "223": return "辽宁盘锦";
            case "224": return "辽宁铁岭";
            case "225": return "辽宁营口";
            case "226": return "内蒙古呼和浩特";
            case "227": return "内蒙古阿拉善盟";
            case "228": return "内蒙古巴彦淖尔";
            case "229": return "内蒙古包头";
            case "230": return "内蒙古赤峰";
            case "231": return "内蒙古鄂尔多斯";
            case "232": return "内蒙古呼伦贝尔";
            case "233": return "内蒙古通辽";
            case "234": return "内蒙古乌海";
            case "235": return "内蒙古乌兰察布";
            case "236": return "内蒙古锡林郭勒盟";
            case "237": return "内蒙古兴安盟";
            case "238": return "宁夏银川";
            case "239": return "宁夏固原";
            case "240": return "宁夏石嘴山";
            case "241": return "宁夏吴忠";
            case "242": return "宁夏中卫";
            case "243": return "青海西宁";
            case "244": return "青海果洛";
            case "245": return "青海海北";
            case "246": return "青海海东";
            case "247": return "青海海南";
            case "248": return "青海海西";
            case "249": return "青海黄南";
            case "250": return "青海玉树";
            case "251": return "山东济南";
            case "252": return "山东滨州";
            case "253": return "山东德州";
            case "254": return "山东东营";
            case "255": return "山东菏泽";
            case "256": return "山东济宁";
            case "257": return "山东莱芜";
            case "258": return "山东聊城";
            case "259": return "山东临沂";
            case "260": return "山东青岛";
            case "261": return "山东日照";
            case "262": return "山东泰安";
            case "263": return "山东威海";
            case "264": return "山东潍坊";
            case "265": return "山东烟台";
            case "266": return "山东枣庄";
            case "267": return "山东淄博";
            case "268": return "山西太原";
            case "269": return "山西长治";
            case "270": return "山西大同";
            case "271": return "山西晋城";
            case "272": return "山西晋中";
            case "273": return "山西临汾";
            case "274": return "山西吕梁";
            case "275": return "山西朔州";
            case "276": return "山西忻州";
            case "277": return "山西阳泉";
            case "278": return "山西运城";
            case "279": return "陕西西安";
            case "280": return "陕西安康";
            case "281": return "陕西宝鸡";
            case "282": return "陕西汉中";
            case "283": return "陕西商洛";
            case "284": return "陕西铜川";
            case "285": return "陕西渭南";
            case "286": return "陕西咸阳";
            case "287": return "陕西延安";
            case "288": return "陕西榆林";
            case "289": return "上海上海";
            case "290": return "四川成都";
            case "291": return "四川阿坝";
            case "292": return "四川巴中";
            case "293": return "四川达州";
            case "294": return "四川德阳";
            case "295": return "四川甘孜";
            case "296": return "四川广安";
            case "297": return "四川广元";
            case "298": return "四川乐山";
            case "299": return "四川凉山";
            case "300": return "四川泸州";
            case "301": return "四川眉山";
            case "302": return "四川绵阳";
            case "303": return "四川内江";
            case "304": return "四川南充";
            case "305": return "四川攀枝花";
            case "306": return "四川遂宁";
            case "307": return "四川雅安";
            case "308": return "四川宜宾";
            case "309": return "四川资阳";
            case "310": return "四川自贡";
            case "311": return "天津天津";
            case "312": return "西藏拉萨";
            case "313": return "西藏阿里";
            case "314": return "西藏昌都";
            case "315": return "西藏林芝";
            case "316": return "西藏那曲";
            case "317": return "西藏日喀则";
            case "318": return "西藏山南";
            case "319": return "新疆乌鲁木齐";
            case "320": return "新疆阿克苏";
            case "321": return "新疆阿拉尔";
            case "322": return "新疆阿勒泰";
            case "323": return "新疆巴音郭楞";
            case "324": return "新疆博尔塔拉";
            case "325": return "新疆昌吉";
            case "326": return "新疆哈密";
            case "327": return "新疆和田";
            case "328": return "新疆喀什";
            case "329": return "新疆克拉玛依";
            case "330": return "新疆克孜勒苏";
            case "331": return "新疆石河子";
            case "332": return "新疆塔城";
            case "333": return "新疆图木舒克";
            case "334": return "新疆吐鲁番";
            case "335": return "新疆五家渠";
            case "336": return "新疆伊犁";
            case "337": return "云南昆明";
            case "338": return "云南保山";
            case "339": return "云南楚雄";
            case "340": return "云南大理";
            case "341": return "云南德宏";
            case "342": return "云南迪庆";
            case "343": return "云南红河";
            case "344": return "云南丽江";
            case "345": return "云南临沧";
            case "346": return "云南怒江";
            case "347": return "云南普洱";
            case "348": return "云南曲靖";
            case "349": return "云南文山";
            case "350": return "云南西双版纳";
            case "351": return "云南玉溪";
            case "352": return "云南昭通";
            case "353": return "浙江杭州";
            case "354": return "浙江湖州";
            case "355": return "浙江嘉兴";
            case "356": return "浙江金华";
            case "357": return "浙江丽水";
            case "358": return "浙江宁波";
            case "359": return "浙江衢州";
            case "360": return "浙江绍兴";
            case "361": return "浙江台州";
            case "362": return "浙江温州";
            case "363": return "浙江舟山";
        }
        return no_pc_name;
    }
    public static string pc_name_NameToId(string pc_name)
    {
        if (pc_name == null || pc_name.Length < 3)
        {
            return no_pc_name_Id;
        }
        switch (pc_name)
        {
            case "安徽合肥": return "1";
            case "安徽安庆": return "2";
            case "安徽蚌埠": return "3";
            case "安徽亳州": return "4";
            case "安徽巢湖": return "5";
            case "安徽池州": return "6";
            case "安徽滁州": return "7";
            case "安徽阜阳": return "8";
            case "安徽淮北": return "9";
            case "安徽淮南": return "10";
            case "安徽黄山": return "11";
            case "安徽六安": return "12";
            case "安徽马鞍山": return "13";
            case "安徽宿州": return "14";
            case "安徽铜陵": return "15";
            case "安徽芜湖": return "16";
            case "安徽宣城": return "17";
            case "北京北京": return "18";
            case "重庆重庆": return "19";
            case "福建福州": return "20";
            case "福建龙岩": return "21";
            case "福建南平": return "22";
            case "福建宁德": return "23";
            case "福建莆田": return "24";
            case "福建泉州": return "25";
            case "福建三明": return "26";
            case "福建厦门": return "27";
            case "福建漳州": return "28";
            case "甘肃兰州": return "29";
            case "甘肃白银": return "30";
            case "甘肃定西": return "31";
            case "甘肃甘南": return "32";
            case "甘肃嘉峪关": return "33";
            case "甘肃金昌": return "34";
            case "甘肃酒泉": return "35";
            case "甘肃临夏": return "36";
            case "甘肃陇南": return "37";
            case "甘肃平凉": return "38";
            case "甘肃庆阳": return "39";
            case "甘肃天水": return "40";
            case "甘肃武威": return "41";
            case "甘肃张掖": return "42";
            case "广东广州": return "43";
            case "广东深圳": return "44";
            case "广东东莞": return "45";
            case "广东珠海": return "46";
            case "广东中山": return "47";
            case "广东佛山": return "48";
            case "广东潮州": return "49";
            case "广东河源": return "50";
            case "广东惠州": return "51";
            case "广东江门": return "52";
            case "广东揭阳": return "53";
            case "广东茂名": return "54";
            case "广东梅州": return "55";
            case "广东清远": return "56";
            case "广东汕头": return "57";
            case "广东汕尾": return "58";
            case "广东韶关": return "59";
            case "广东阳江": return "60";
            case "广东云浮": return "61";
            case "广东湛江": return "62";
            case "广东肇庆": return "63";
            case "广西南宁": return "64";
            case "广西百色": return "65";
            case "广西北海": return "66";
            case "广西崇左": return "67";
            case "广西防城港": return "68";
            case "广西贵港": return "69";
            case "广西桂林": return "70";
            case "广西河池": return "71";
            case "广西贺州": return "72";
            case "广西来宾": return "73";
            case "广西柳州": return "74";
            case "广西钦州": return "75";
            case "广西梧州": return "76";
            case "广西玉林": return "77";
            case "贵州贵阳": return "78";
            case "贵州安顺": return "79";
            case "贵州毕节": return "80";
            case "贵州六盘水": return "81";
            case "贵州黔东南": return "82";
            case "贵州黔南": return "83";
            case "贵州黔西南": return "84";
            case "贵州铜仁": return "85";
            case "贵州遵义": return "86";
            case "海南海口": return "87";
            case "海南白沙": return "88";
            case "海南保亭": return "89";
            case "海南昌江": return "90";
            case "海南澄迈": return "91";
            case "海南儋州": return "92";
            case "海南定安": return "93";
            case "海南东方": return "94";
            case "海南乐东": return "95";
            case "海南临高": return "96";
            case "海南陵水": return "97";
            case "海南琼海": return "98";
            case "海南琼中": return "99";
            case "海南三亚": return "100";
            case "海南屯昌": return "101";
            case "海南万宁": return "102";
            case "海南文昌": return "103";
            case "海南五指山": return "104";
            case "海南西南中沙群岛办事处": return "105";
            case "河北石家庄": return "106";
            case "河北保定": return "107";
            case "河北沧州": return "108";
            case "河北承德": return "109";
            case "河北邯郸": return "110";
            case "河北衡水": return "111";
            case "河北廊坊": return "112";
            case "河北秦皇岛": return "113";
            case "河北唐山": return "114";
            case "河北邢台": return "115";
            case "河北张家口": return "116";
            case "河南郑州": return "117";
            case "河南安阳": return "118";
            case "河南鹤壁": return "119";
            case "河南济源": return "120";
            case "河南焦作": return "121";
            case "河南开封": return "122";
            case "河南洛阳": return "123";
            case "河南漯河": return "124";
            case "河南南阳": return "125";
            case "河南平顶山": return "126";
            case "河南濮阳": return "127";
            case "河南三门峡": return "128";
            case "河南商丘": return "129";
            case "河南新乡": return "130";
            case "河南信阳": return "131";
            case "河南许昌": return "132";
            case "河南周口": return "133";
            case "河南驻马店": return "134";
            case "黑龙江哈尔滨": return "135";
            case "黑龙江大庆": return "136";
            case "黑龙江大兴安岭": return "137";
            case "黑龙江鹤岗": return "138";
            case "黑龙江黑河": return "139";
            case "黑龙江鸡西": return "140";
            case "黑龙江佳木斯": return "141";
            case "黑龙江牡丹江": return "142";
            case "黑龙江七台河": return "143";
            case "黑龙江齐齐哈尔": return "144";
            case "黑龙江双鸭山": return "145";
            case "黑龙江绥化": return "146";
            case "黑龙江伊春": return "147";
            case "湖北武汉": return "148";
            case "湖北鄂州": return "149";
            case "湖北恩施": return "150";
            case "湖北黄冈": return "151";
            case "湖北黄石": return "152";
            case "湖北荆门": return "153";
            case "湖北荆州": return "154";
            case "湖北潜江": return "155";
            case "湖北神农架林区": return "156";
            case "湖北十堰": return "157";
            case "湖北随州": return "158";
            case "湖北天门": return "159";
            case "湖北仙桃": return "160";
            case "湖北咸宁": return "161";
            case "湖北襄樊": return "162";
            case "湖北孝感": return "163";
            case "湖北宜昌": return "164";
            case "湖南长沙": return "165";
            case "湖南常德": return "166";
            case "湖南郴州": return "167";
            case "湖南衡阳": return "168";
            case "湖南怀化": return "169";
            case "湖南娄底": return "170";
            case "湖南邵阳": return "171";
            case "湖南湘潭": return "172";
            case "湖南湘西": return "173";
            case "湖南益阳": return "174";
            case "湖南永州": return "175";
            case "湖南岳阳": return "176";
            case "湖南张家界": return "177";
            case "湖南株洲": return "178";
            case "吉林长春": return "179";
            case "吉林白城": return "180";
            case "吉林白山": return "181";
            case "吉林吉林": return "182";
            case "吉林辽源": return "183";
            case "吉林四平": return "184";
            case "吉林松原": return "185";
            case "吉林通化": return "186";
            case "吉林延吉": return "187";
            case "江苏南京": return "188";
            case "江苏常州": return "189";
            case "江苏淮安": return "190";
            case "江苏连云港": return "191";
            case "江苏南通": return "192";
            case "江苏苏州": return "193";
            case "江苏宿迁": return "194";
            case "江苏泰州": return "195";
            case "江苏无锡": return "196";
            case "江苏徐州": return "197";
            case "江苏盐城": return "198";
            case "江苏扬州": return "199";
            case "江苏镇江": return "200";
            case "江西南昌": return "201";
            case "江西抚州": return "202";
            case "江西赣州": return "203";
            case "江西吉安": return "204";
            case "江西景德镇": return "205";
            case "江西九江": return "206";
            case "江西萍乡": return "207";
            case "江西上饶": return "208";
            case "江西新余": return "209";
            case "江西宜春": return "210";
            case "江西鹰潭": return "211";
            case "辽宁沈阳": return "212";
            case "辽宁鞍山": return "213";
            case "辽宁本溪": return "214";
            case "辽宁朝阳": return "215";
            case "辽宁大连": return "216";
            case "辽宁丹东": return "217";
            case "辽宁抚顺": return "218";
            case "辽宁阜新": return "219";
            case "辽宁葫芦岛": return "220";
            case "辽宁锦州": return "221";
            case "辽宁辽阳": return "222";
            case "辽宁盘锦": return "223";
            case "辽宁铁岭": return "224";
            case "辽宁营口": return "225";
            case "内蒙古呼和浩特": return "226";
            case "内蒙古阿拉善盟": return "227";
            case "内蒙古巴彦淖尔": return "228";
            case "内蒙古包头": return "229";
            case "内蒙古赤峰": return "230";
            case "内蒙古鄂尔多斯": return "231";
            case "内蒙古呼伦贝尔": return "232";
            case "内蒙古通辽": return "233";
            case "内蒙古乌海": return "234";
            case "内蒙古乌兰察布": return "235";
            case "内蒙古锡林郭勒盟": return "236";
            case "内蒙古兴安盟": return "237";
            case "宁夏银川": return "238";
            case "宁夏固原": return "239";
            case "宁夏石嘴山": return "240";
            case "宁夏吴忠": return "241";
            case "宁夏中卫": return "242";
            case "青海西宁": return "243";
            case "青海果洛": return "244";
            case "青海海北": return "245";
            case "青海海东": return "246";
            case "青海海南": return "247";
            case "青海海西": return "248";
            case "青海黄南": return "249";
            case "青海玉树": return "250";
            case "山东济南": return "251";
            case "山东滨州": return "252";
            case "山东德州": return "253";
            case "山东东营": return "254";
            case "山东菏泽": return "255";
            case "山东济宁": return "256";
            case "山东莱芜": return "257";
            case "山东聊城": return "258";
            case "山东临沂": return "259";
            case "山东青岛": return "260";
            case "山东日照": return "261";
            case "山东泰安": return "262";
            case "山东威海": return "263";
            case "山东潍坊": return "264";
            case "山东烟台": return "265";
            case "山东枣庄": return "266";
            case "山东淄博": return "267";
            case "山西太原": return "268";
            case "山西长治": return "269";
            case "山西大同": return "270";
            case "山西晋城": return "271";
            case "山西晋中": return "272";
            case "山西临汾": return "273";
            case "山西吕梁": return "274";
            case "山西朔州": return "275";
            case "山西忻州": return "276";
            case "山西阳泉": return "277";
            case "山西运城": return "278";
            case "陕西西安": return "279";
            case "陕西安康": return "280";
            case "陕西宝鸡": return "281";
            case "陕西汉中": return "282";
            case "陕西商洛": return "283";
            case "陕西铜川": return "284";
            case "陕西渭南": return "285";
            case "陕西咸阳": return "286";
            case "陕西延安": return "287";
            case "陕西榆林": return "288";
            case "上海上海": return "289";
            case "四川成都": return "290";
            case "四川阿坝": return "291";
            case "四川巴中": return "292";
            case "四川达州": return "293";
            case "四川德阳": return "294";
            case "四川甘孜": return "295";
            case "四川广安": return "296";
            case "四川广元": return "297";
            case "四川乐山": return "298";
            case "四川凉山": return "299";
            case "四川泸州": return "300";
            case "四川眉山": return "301";
            case "四川绵阳": return "302";
            case "四川内江": return "303";
            case "四川南充": return "304";
            case "四川攀枝花": return "305";
            case "四川遂宁": return "306";
            case "四川雅安": return "307";
            case "四川宜宾": return "308";
            case "四川资阳": return "309";
            case "四川自贡": return "310";
            case "天津天津": return "311";
            case "西藏拉萨": return "312";
            case "西藏阿里": return "313";
            case "西藏昌都": return "314";
            case "西藏林芝": return "315";
            case "西藏那曲": return "316";
            case "西藏日喀则": return "317";
            case "西藏山南": return "318";
            case "新疆乌鲁木齐": return "319";
            case "新疆阿克苏": return "320";
            case "新疆阿拉尔": return "321";
            case "新疆阿勒泰": return "322";
            case "新疆巴音郭楞": return "323";
            case "新疆博尔塔拉": return "324";
            case "新疆昌吉": return "325";
            case "新疆哈密": return "326";
            case "新疆和田": return "327";
            case "新疆喀什": return "328";
            case "新疆克拉玛依": return "329";
            case "新疆克孜勒苏": return "330";
            case "新疆石河子": return "331";
            case "新疆塔城": return "332";
            case "新疆图木舒克": return "333";
            case "新疆吐鲁番": return "334";
            case "新疆五家渠": return "335";
            case "新疆伊犁": return "336";
            case "云南昆明": return "337";
            case "云南保山": return "338";
            case "云南楚雄": return "339";
            case "云南大理": return "340";
            case "云南德宏": return "341";
            case "云南迪庆": return "342";
            case "云南红河": return "343";
            case "云南丽江": return "344";
            case "云南临沧": return "345";
            case "云南怒江": return "346";
            case "云南普洱": return "347";
            case "云南曲靖": return "348";
            case "云南文山": return "349";
            case "云南西双版纳": return "350";
            case "云南玉溪": return "351";
            case "云南昭通": return "352";
            case "浙江杭州": return "353";
            case "浙江湖州": return "354";
            case "浙江嘉兴": return "355";
            case "浙江金华": return "356";
            case "浙江丽水": return "357";
            case "浙江宁波": return "358";
            case "浙江衢州": return "359";
            case "浙江绍兴": return "360";
            case "浙江台州": return "361";
            case "浙江温州": return "362";
            case "浙江舟山": return "363";
        }
        return no_pc_name_Id;
    }
    public static string P31_NameToP_C(string p_name)
    {
        if (p_name == null || p_name.Length < 2)
        {
            return "";
        }
        switch (p_name)
        {
            case "安徽": return "安徽合肥";
            case "北京": return "北京北京";
            case "重庆": return "重庆重庆";
            case "福建": return "福建福州";
            case "甘肃": return "甘肃兰州";
            case "广东": return "广东广州";
            case "广西": return "广西南宁";
            case "贵州": return "贵州贵阳";
            case "海南": return "海南海口";
            case "河北": return "河北石家庄";
            case "河南": return "河南郑州";
            case "黑龙江": return "黑龙江哈尔滨";
            case "湖北": return "湖北武汉";
            case "湖南": return "湖南长沙";
            case "吉林": return "吉林长春";
            case "江苏": return "江苏南京";
            case "江西": return "江西南昌";
            case "辽宁": return "辽宁盘锦";
            case "内蒙古": return "内蒙古呼和浩特";
            case "宁夏": return "宁夏银川";
            case "青海": return "青海西宁";
            case "山东": return "山东济南";
            case "山西": return "山西太原";
            case "陕西": return "陕西西安";
            case "上海": return "上海上海";
            case "四川": return "四川成都";
            case "天津": return "天津天津";
            case "西藏": return "西藏拉萨";
            case "新疆": return "新疆乌鲁木齐";
            case "云南": return "云南昆明";
            case "浙江": return "浙江杭州";
        }
        return "";
    }

    /// <summary>
    /// 验证银行卡号格式是否正确
    /// 返回结果，如果result=0表示银行卡校验未通过，result>0表示卡校验已通过
    /// result=1贷记卡(信用卡)，result=2借记卡(普通银行卡)，result=3预付费卡，result=4准贷记卡)
    /// </summary>
    /// <returns></returns>
    public static string readurl_checkcardno(string cardno)
    {
        if (cardno == null || cardno.Length < 6)
        {
            return "0";
        }
        bool suc = false;
        Model.ReadResult read = readAuthorizeUrl<Model.ReadResult>("http://api.ulpos.com/v1/verify/checkcardno", "&cardno=" + cardno, out suc);
        if (suc && read != null)
        {
            if (read.data != null && read.data.Count > 0 && read.data[0] != null)
            {
                return read.data[0].result;
            }
        }
        return "0";
    }
    public static string check_cardno(string check_cardno,out bool flag,out string bankname)
    {
        flag = false;
        bankname = "";
        string cardno = "";
        if (check_cardno != null && check_cardno.Length > 9)
        {
            cardno = check_cardno.Trim();
        }
        else
        {
            return ("银行卡号不正确！");
        }
        if (cardno != null && cardno.Length > 9)
        {
            try
            {
                if (!is_bankno(cardno))
                {
                    flag = false;
                    return ("银行卡号不正确！");
                }
            }
            catch
            {
                flag = false;
                return ("银行卡号不正确！");
            }
            string ckstr = readurl_checkcardno(cardno);
            if ("0".Equals(ckstr))
            {
                flag = false;
                return ("银行卡号不正确！");
            }
            bankname = Getbankname.getbankName(cardno);
            flag = true;
            return ("");
        }
        flag = false;
        return ("银行卡号不正确！");
    }
    private static readonly string RegexEmail = @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$";
    public static bool isEmail(string searchTxt)
    {
        try
        {
            System.Text.RegularExpressions.Regex RegExp = new System.Text.RegularExpressions.Regex(RegexEmail, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            if (RegExp.IsMatch(searchTxt))
            {
                return true;
            }
        }
        catch
        {
            return false;
        }
        return false;
    }
    private static readonly string Regex_bankno = @"^[1-9][0-9]{8,37}$";
    public static bool is_bankno(string searchTxt)
    {
        try
        {
            System.Text.RegularExpressions.Regex RegExp = new System.Text.RegularExpressions.Regex(Regex_bankno, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            if (RegExp.IsMatch(searchTxt))
            {
                return true;
            }
        }
        catch
        {
            return false;
        }
        return false;
    }
}